import Vue from 'vue'
import App from './App.vue'
import router from './router/index'

//引入样式初始化
// import './style/reset.css'
// import './style/iconfont.css'
import { Image as VanImage } from 'vant';
import { Dialog } from 'vant';
Vue.use(Dialog);
import { NavBar } from 'vant';
import { Icon } from 'vant'
import { Uploader } from 'vant';
import { Field } from 'vant';
import { Notify } from 'vant'
import { ActionSheet } from 'vant';
import { Tab, Tabs } from 'vant';
import { List } from 'vant';
import { Button } from 'vant';
import { SwipeCell } from 'vant'
import { Empty } from 'vant';
import { Search } from 'vant';
import { RadioGroup, Radio } from 'vant';
import { Cell, CellGroup } from 'vant';
import { Popup } from 'vant';
import { Loading } from 'vant';
import { Checkbox, CheckboxGroup } from 'vant';

Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Loading);
Vue.use(Popup);
Vue.use(Search);
Vue.use(Empty);
Vue.use(SwipeCell)
Vue.use(Button);
Vue.use(List);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(ActionSheet);
Vue.use(Notify)
Vue.use(Field);
Vue.use(Uploader);
Vue.use(Icon)
Vue.use(NavBar);
Vue.use(VanImage);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Cell);
Vue.use(CellGroup);
Vue.config.productionTip = false
import { PullRefresh } from 'vant';

Vue.use(PullRefresh);
import request from './utils/request'
import defaultImg from './assets/logo.png'



// 全局过滤器 - 在任意组件都能调用
Vue.filter('imgUrl', (val) => {
  if (!val) {
    return defaultImg
  }
  //如果路径不存在http，那么就加上基地址
  if (val.indexOf('http') === -1) {
    return request.defaults.baseURL + val
  } else {
    // 如果是http开头就 返回原路径
    return val
  }
})
// 时间全局过滤
Vue.filter('formdate', (val) => {
  if (val) {
    return val.replace('T', ' ').replace('.000Z', '')
  }
})
// 自定义指令
Vue.directive('focus', {
  update(el) {
    el.focus()
  },
})
//局部引入组件
import { Toast } from 'vant';
// console.log(typeof Toast);  //请提示是一个功能函数 调用要this.$toast
Vue.use(Toast);
new Vue({
  //注入vue实例
  router,
  render: h => h(App),
}).$mount('#app')
